<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="UTF-8">
      <title>事件对象</title>
   </head>
   <body>
      <input type="text">
      <script>
         let tx = document.querySelector('input')
         tx.addEventListener('keyup', function(e){
            // console.log(e)
            if (e.key === 'Enter'){
               alert('输入了回车')
               // console.log('输入回车')
            }
         })
      </script>
   </body>
</html>